<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>jack</h1>
<button type="button" onclick="socket.close()">下线</button>
<button type="button" onclick="socket.send('hello jack')">发送</button>
</body>

<script>
    let socket ;
    onload = () =>{
        if(!window.WebSocket){
            alert('不支持websocket');
            return;
        }
        socket = new WebSocket("ws://localhost:5279/api/v1/danmu-server/jack");
        socket.onopen = () =>{
            console.log('jack连接成功');
        };
        socket.onclose = () =>{
            console.log('jack连接关闭');
        };
        socket.onclose = () =>{
            console.log('jack连接关闭');
        };
        socket.onmessage = resp =>{
            console.log(resp.data);
        };
    }
</script>
</html>